import 'package:flutter/material.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:practice_project/home_page.dart';

void main() {

  // 屏幕启动
  WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized();
  FlutterNativeSplash.preserve(widgetsBinding: widgetsBinding);
  initialization();

  runApp(const MyApp());
}

 @override
  void initState() {
    initialization();
  }

// 启动图延时移除方法
void initialization() async {
    // ignore_for_file: avoid_print
    print('Splash screen in 3...');
    await Future.delayed(const Duration(seconds: 1));
    print('Splash screen in 2...');
    await Future.delayed(const Duration(seconds: 1));
    print('Splash screen in 1...');
    await Future.delayed(const Duration(seconds: 1));
    print('go!');
    FlutterNativeSplash.remove();
  }

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blueGrey,
      ),
      home: const HomePage(title: 'Flutter Demos'),
    );
  }
}
